<template>
	<view>获取商品</view>
	<view class="shop">
		<view v-for="(item, index) in shops" :key="index" class="shopbox">
			<image class="shopimg" :src="item.brand_logo"></image>
			<view class="shopname">{{item.brand_name}}</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			shops: [], // 用于存储商品数据的数组
		};
	},
	onLoad() {
	  this.getShop();
	},
	methods: {
		getShop() {
			uni.request({
				url: 'https://manage.jwk2022.cn/openapiv2/index/getJdPddBrand', 
				method: 'POST',
				data: {
					'cate_id': '1',
					'source_type': 'pdd',
					// 'appid': '',
				},
				header: {
					'content-type': 'application/x-www-form-urlencoded' 
				},
				success: (res) => {
					if (res.data.code === 1) {
						this.shops = res.data.data;
						console.log(this.shops); // 打印获取到的商品数据
					} else {
						console.error('获取Shop数据失败');
					}
				},
				fail: (err) => {
					console.error(err);
				},
				complete: () => {
				}
			});
		}
	}
};
</script>

<style>
	.shop {
		padding: 2%;
		display: flex;
		flex-wrap: wrap;
		gap: 2%;
	}
	.shopbox {
		width: 48%;
	}
	.shopname {
		font-size: 15px;
		text-align: center;
	}
	.shopimg {
		width: 100%;
		height: 150px;
	}
</style>